import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;


public class ScheduleAnalyzerTest {
	private ScheduleAnalyzer scheduler;

	@Before
	public void setUp() {
	    scheduler = new ScheduleAnalyzer("TestFlight1", "Dallas", "New York");
	}
	
	@Test
	public void testInitValues() {
		System.out.format("Testing init values.%n");
		assertEquals("TestFlight1", scheduler.getFlightNum());
		assertEquals("Dallas", scheduler.getOrigin());
		assertEquals("New York", scheduler.getDestination());
	}
	
	@Test
	public void testWeather() {
		System.out.format("Testing setWeather()%n");
		assertEquals(0, scheduler.getWeatherOrigin());
		assertEquals(0, scheduler.getWeatherDest());
		scheduler.setWeatherOrigin(1);
		assertEquals(1, scheduler.getWeatherOrigin());
		scheduler.setWeatherDest(1);
		assertEquals(1, scheduler.getWeatherDest());
		scheduler.setWeatherOrigin(2);
		assertEquals(2, scheduler.getWeatherOrigin());
		scheduler.setWeatherDest(2);
		assertEquals(2, scheduler.getWeatherDest());
		scheduler.setWeatherOrigin(3);
		assertEquals(3, scheduler.getWeatherOrigin());
		scheduler.setWeatherDest(3);
		assertEquals(3, scheduler.getWeatherDest());
		scheduler.setWeatherOrigin(6);
		assertEquals(6, scheduler.getWeatherOrigin());
		scheduler.setWeatherDest(5);
		assertEquals(5, scheduler.getWeatherDest());
	}

	@Test
	public void testComputeWeatherAffects() {
		System.out.format("Testing computWeatherAffects()%n");
		int affects0 = scheduler.computeWeatherAffects(0);
		int affects1 = scheduler.computeWeatherAffects(1);
		int affects2 = scheduler.computeWeatherAffects(2);
		int affects3 = scheduler.computeWeatherAffects(3);
		int affects4 = scheduler.computeWeatherAffects(4);
		int affects5 = scheduler.computeWeatherAffects(5);
		int affects6 = scheduler.computeWeatherAffects(6);
		
		assertEquals(0, affects0);
		assertEquals(-1, affects6);
		assertTrue(affects0 < affects1);
		assertTrue(affects1 < affects2);
		assertTrue(affects2 < affects3);
		assertTrue(affects3 < affects4);
		assertTrue(affects4 < affects5);
	}
	
	@Test
	public void testHistoricalAffects() {
		System.out.format("Testing affects of historical schedule()%n");
		// First lets set the historical times to 0.
		int initialTakeoffTime;
		int initialArrivalTime;
		int finalTakeoffTime;
		int finalArrivalTime;
		int takeoffTimeSchedule = 10;
		int arrivalTimeSchedule = 20;
		scheduler.setHistoricalTakeoffTime(0);
		scheduler.setHistoricalArrivalTime(0);
		
		initialTakeoffTime = scheduler.getTakeOffTime();
		initialArrivalTime = scheduler.getArrivalTime();
		
		scheduler.setHistoricalTakeoffTime(takeoffTimeSchedule);
		scheduler.setHistoricalArrivalTime(arrivalTimeSchedule);
		
		finalTakeoffTime = scheduler.getTakeOffTime();
        finalArrivalTime = scheduler.getArrivalTime();
        
        assertEquals(takeoffTimeSchedule, (finalTakeoffTime - initialTakeoffTime));
        assertEquals((takeoffTimeSchedule + arrivalTimeSchedule), (finalArrivalTime - initialArrivalTime));
	}

	private void setHistoricalArrivalTime(int i) {
		// TODO Auto-generated method stub
		
	}

	private void setHistoricalTakeoffTime(int i) {
		// TODO Auto-generated method stub
		
	}
}
